package com.ldk.api;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonArray;
import com.ldk.base.framework.common.CustomPageable;
import com.ldk.base.framework.util.ConvertUtil;
import com.ldk.base.framework.util.HttpUtil;
import com.ldk.base.framework.util.SignUtil;
import com.ldk.base.framework.util.baidu.AddressComponentApi;
import com.ldk.base.framework.util.baidu.RouteMatrixApi;
import com.ldk.base.framework.util.baidu.routematrix.RouteMatrixRequestParms;
import com.ldk.base.framework.util.baidu.routematrix.RouteMatrixResponseParmsResult;
import com.ldk.framework.entity.AdminUser;
import com.ldk.framework.entity.Companypermit;
import com.ldk.framework.service.ICompanypermitService;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;

import java.awt.JobAttributes;
import java.util.HashMap;
import java.util.Map;

/**
 * 上报数据接口测试
 *
 * @author mqy
 * 2017年2月25日
 * com.ldk.api
 * TestApi
 */
public class TestReportDataApi {

    @Autowired
    private ICompanypermitService companypermitService;

    public static void main(String[] args) {
        String res=postService("baselnfoCompanyPermit");
        //System.out.println("validCode:" + validCode);
    }


    public static void baselnfoCompanyPermit() {



    }


    public static String postService(String method) {
        String response = HttpUtil.get("http://127.0.0.1:8080/reportdata/uploaddata", "method=" + method, null);
        System.out.print("response=" + response);

        return  response;
    }

    /**
     * 请求接口
     *
     * @param url    访问路径
     * @param method 方法
     * @param arrays  list
     * @return
     */
    protected static JSONObject requestService(String url, String method, JsonArray arrays) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("CompanyId", "1200DDCX3307");
        jsonObject.put("Source", "0");
        jsonObject.put("IPCType", method);
        jsonObject.put(method, arrays);
        String json = JSON.toJSONString(jsonObject);
        //String sign = SignUtil.encrypt(json, 1, "ldk@api");
        Map<String, String> headers = new HashMap<String, String>();
        //headers.put("sign", sign);
        //headers.put("sign", sign);

        String response = HttpUtil.post("http://czc.tyxxtb.com/" + url, json, headers);
        System.out.print("response=" + response);
        JSONObject responseObject = new JSONObject();
        if (!StringUtils.isEmpty(response)) {
            responseObject = JSON.parseObject(response);
        }
        return responseObject;
    }


}
